/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 14-8-2
 * Time: 上午1:36
 * To change this template use File | Settings | File Templates.
 */

var CHAT_KEY = "chat";
var CHAT_NAME_KEY = "chatName";
var CURRENT_CHAT_ROOM_KEY = "currentChatRoom";

var chatRooms = [
    {name: "NEWS", label: "新闻"},
    {name: "SPORTS", label: "体育"},
    {name: "ENTERTAINMENT", label: "娱乐"},
    {name: "FINANCE", label: "财经"},
    {name: "STOCK", label: "股票"},
    {name: "CAR", label: "汽车"},
    {name: "TECHNOLOGY", label: "科技"},
    {name: "PHONE", label: "手机"},
    {name: "DIGITAL", label: "数码"},
    {name: "HOUSE", label: "房产"},
    {name: "FURNITURE", label: "家居"},
    {name: "EDUCATION", label: "教育"},
    {name: "BOOK", label: "读书"},
    {name: "GAME", label: "游戏"},
    {name: "LOTTERY", label: "彩票"}
];

var goToChat = function (value) {
    var chatName = $.cookie(CHAT_NAME_KEY);
    $.cookie(CHAT_KEY, value);

    chatRooms.forEach(function (data) {
        if (data.name == value) {
            var jsonResult = JSON.stringify(data);
            $.cookie(CURRENT_CHAT_ROOM_KEY, jsonResult);
        }
    });

    if (chatName) {
        location.href = "chat.html";
    } else {
        $('#chatNameDialog').modal('show');
    }
}

function closeChatNameDialog() {
    $('#chatNameDialog').modal('hide');
}